package com.patterns.prototype;

class SheepTest{
	public static void main(String[] args) throws Exception {
		Color color = new Color("白色");
		Sheep s1 = new Sheep("Terry", "山羊",color);
		//Sheep [name=Terry, type=山羊, color=Color [color=白色]]
		System.out.println(s1);
		
		Sheep s2 = (Sheep) s1.clone();
		//Sheep [name=Terry, type=山羊, color=Color [color=白色]]
		System.out.println(s2);
		
		
		//浅复制，只能复制普通属性，对象属性相同
		Sheep s3 = (Sheep) s1.clone();
		s3.getColor().setColor("红色");
		//Sheep [name=Terry, type=山羊, color=Color [color=红色]]
		System.out.println(s3);
		//Sheep [name=Terry, type=山羊, color=Color [color=红色]]
		System.out.println(s1);
		
	}
}
